import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Set;
import java.util.TreeSet;

public class HJ25 {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String line = "";
        while((line = br.readLine()) != null) {
            String I_str = line;//第一行
            String R_str = br.readLine();
            System.out.println(dataClassificate(I_str, R_str));
        }
    }

    public static String dataClassificate(String I_str, String R_str) {
        StringBuilder result = new StringBuilder();//输出最后结果
        String[] I = I_str.split(" ");
        String[] R = R_str.split(" ");
        //将数组R 从小到大排序
        Set<Integer> R_set = new TreeSet<>();
        for(int i = 1; i < R.length; i++) {
            R_set.add(Integer.parseInt(R[i]));
        }
        //遍历R_set
        for (int R_data: R_set) {
            StringBuilder index_and_data = new StringBuilder();
            int containsNum = 0;//数组I包含R_data的个数
            //遍历数组I，判断是否包含R_data
            for (int i = 1; i < I.length; i++) {
                if(I[i].contains(String.valueOf(R_data))) {
                    containsNum++;
                    index_and_data.append(i -1) //索引
                            .append(" ")
                            .append(I[i]) //打印满足条件的I[i]
                            .append(" ");
                }
            }

            if(containsNum != 0) {
                result.append(R_data) //这个R<i>
                        .append(" ")
                        .append(containsNum) //存在几个包含R_data的I<j>
                        .append(" ")
                        .append(index_and_data.toString());//序号 加 I<j>
            }
        }

        int all_num = result.toString().split(" ").length;//后面总共有多少个数
        result.insert(0, all_num + " ");

        return result.toString();
    }
}
